{% extends "base.html" %}
{% load navigation_tags %}
{% load get_config_setting %}
{% block content %}
    {{ block.super }}
    <div class="row">
      <div class="col-md-12">
          <div class="panel panel-default table-responsive">
              <div class="panel-heading">
                  <h4>Engagement Presets
                      <a title="Add New Engagement Preset" class="pull-right btn btn-primary btn-sm"
                         href="{% url 'add_engagement_presets' prod.id %}"><span class="fa-solid fa-plus"></span></a>
                  </h4>
              </div>
              {% if presets %}
                  <table class="tablesorter-bootstrap table table-condensed table-striped table-hover">
                      <thead>
                      <tr>
                        <th>Name</th>
                        <th>Test Type</th>
                        <th>Network</th>
                        <th></th>
                      </tr>
                      </thead>
                      <tbody>
                      {% for preset in presets %}
                          <tr>
                            <td>
                                {{ preset.title }}
                            </td>
                            <td style="width: 400px;">
                              {% if preset.test_type.all.count > 1 %}
                                {% for test in preset.test_type.all %}
                                   {{test.name}}{%if not forloop.last%},{%endif%}
                                {% endfor %}
                              {% else %}
                                {{ preset.test_type.all.0.name }}
                              {% endif %}
                            </td>
                            <td style="width: 400px;">
                              {% if preset.network_locations.all.count > 1 %}
                                {% for net in preset.network_locations.all %}
                                   {{ net.location }}{%if not forloop.last%},{%endif%}
                                {% endfor %}
                              {% else %}
                                {{ preset.network_locations.all.0.location }}
                              {% endif %}
                            </td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn btn-sm btn-warning"
                                       href="{% url 'edit_engagement_presets' preset.product.id preset.id  %}">Edit</a>
                                    <a class="btn btn-sm btn-danger delete-finding"
                                       href="{% url 'delete_engagement_presets' preset.product.id preset.id  %}">Delete</a>
                                </div>
                            </td>
                          </tr>
                      {% endfor %}
                      </tbody>
                  </table>
              {% else %}
                  <div class="panel-body">
                      <p>No engagement presets configured.</p>
                  </div>
              {% endif %}
          </div>
      </div>
    </div>
{% endblock %}
